package cn.mumzone.pos.api.service;


import java.util.HashMap;
import java.util.List;

import cn.mumzone.basic.net.response.BaseResponse;
import cn.mumzone.basic.net.response.PageListResponse;
import cn.mumzone.pos.model.GoodsEntity;
import cn.mumzone.pos.model.GoodsTreeEntity;
import cn.mumzone.pos.model.ReturnEntity;
import cn.mumzone.pos.model.ReturnGoodsEntity;
import okhttp3.RequestBody;
import retrofit2.Response;
import retrofit2.http.Body;
import retrofit2.http.Field;
import retrofit2.http.FieldMap;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.Query;
import rx.Observable;

/**
 * Author Chaney
 * Date   2017/3/7 上午11:15.
 * EMail  qiuzhenhuan.hi@gmail.com
 */
public interface GoodsService {

    /**
     * 商品搜索
     *
     * @param goodsCode
     * @param pageNum
     * @param pageSize
     * @return
     */
    @GET("egg_goods/api/v1/pos/business/searchGoods")
    Observable<Response<BaseResponse<PageListResponse<GoodsEntity>>>> searchGoods(
            @Query("goodsIds") String goodsIds,
            @Query("memberId") String memberId,
            @Query("memberDiscountType") String memberDiscountType,
            @Query("memberDiscount") String memberDiscount,
            @Query("memberRank") String memberRank,
            @Query("goodsCode") String goodsCode,
            @Query("pageNum") String pageNum,
            @Query("pageSize") String pageSize,
            @Query("isScan") String isScan);


    @GET("egg_goods/api/v2.2/pos/business/selectGoodsPrice")
    Observable<Response<BaseResponse<PageListResponse<GoodsEntity>>>> selectGoodsPrice(
            @Query("goodsIds") String goodsIds,
            @Query("memberId") String memberId,
            @Query("memberDiscountType") String memberDiscountType,
            @Query("memberDiscount") String memberDiscount,
            @Query("memberRank") String memberRank);


    /**
     * 搜索积分换购商品
     *
     * @param goodsCode
     * @param pageNum
     * @param pageSize
     * @return
     */
    @GET("egg_goods/api/v2.2/pos/pointsRedemptionGoods")
    Observable<Response<BaseResponse<PageListResponse<GoodsEntity>>>> searchIntegralGoods(@Query("goodsCode") String goodsCode,
                                                                                          @Query("pageNum") String pageNum,
                                                                                          @Query("pageSize") String pageSize);

    /**
     * 添加商品到购物车
     *
     * @param body
     * @return
     */
    @POST("egg_goods/api/v1/pos/business/addGoodsToCart")
    Observable<Response<BaseResponse<String>>> addGoodsToCart(@Body RequestBody body);


    /**
     * 批量添加商品到购物车
     *
     * @param body
     * @return
     */
    @POST("egg_goods/api/v1/pos/business/addGoodsToCartBatch")
    Observable<Response<BaseResponse<String>>> addGoodsToCartBatch(@Body RequestBody body);


    /**
     * 退货商品搜索
     *
     * @param goodsCode
     * @return
     */
    @FormUrlEncoded
    @POST("egg_goods/api/v2/pos/returnedGoods/searchGoodsForReturn")
    Observable<Response<BaseResponse<List<ReturnGoodsEntity>>>> searchGoodsForReturn(@Field("orderCode") String orderCode,
                                                                                     @Field("goodsCode") String goodsCode);


    /**
     * 确认退货
     *
     * @param goodsList
     * @param orderCode
     * @param returnAmount
     * @param returnMargin
     * @return
     */
    @FormUrlEncoded
    @POST("egg_goods/api/v2/pos/returnedGoods/confirmForReturn")
    Observable<Response<BaseResponse<List<ReturnEntity>>>> confirmForReturn(@Field("goodsList") String goodsList,
                                                                            @Field("orderCode") String orderCode,
                                                                            @Field("returnAmount") String returnAmount,
                                                                            @Field("returnMargin") String returnMargin,
                                                                            @Field("posCode") String posCode
    );

    /**
     * 获取购物车列表
     *
     * @param storeId
     * @return
     */
    @GET("egg_goods/api/v1/pos/business/getCartGoods")
    Observable<Response<BaseResponse<List<GoodsEntity>>>> getCartGoods(@Query("storeId") String storeId);

    /**
     * 清空购物车
     *
     * @param storeId
     * @return
     */
    @GET("egg_goods/api/v1/pos/business/clearCartGoods")
    Observable<Response<BaseResponse<String>>> clearCartGoods(@Query("storeId") String storeId);


    /**
     * 移除购物车商品
     *
     * @param storeId
     * @param goodsId
     * @param goodsSpec
     */
    @FormUrlEncoded
    @POST("egg_goods/api/v1/pos/business/removeCartGoods")
    Observable<Response<BaseResponse<String>>> removeGoodsById(@Field("storeId") String storeId,
                                                               @Field("goodsId") String goodsId,
                                                               @Field("goodsSpec") String goodsSpec);


    /**
     * @param requestMap
     * @return
     */
    @FormUrlEncoded
    @POST("egg_goods/api/v1.3/pos/endBill/refundPayCallBackToPhysicalStore")
    Observable<Response<BaseResponse<List<ReturnEntity>>>> refundPayCallBackToPhysicalStore(@FieldMap HashMap<String,
            String> requestMap);


    /**
     * 获取商品分类树
     *
     * @return
     */
    @GET("egg_goods/api/v1/classify/getGoodsClassifyTreeList")
    Observable<Response<BaseResponse<List<GoodsTreeEntity>>>> getGoodsClassifyTreeList();

}
